import { createRouter, createWebHistory } from 'vue-router'
import MainLayout from '@/layouts/MainLayout.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: MainLayout,
      redirect: '/dashboard',
      children: [
        {
          path: 'dashboard',
          name: 'Dashboard',
          component: () => import('@/views/Dashboard.vue'),
          meta: { title: '首页' },
        },
        {
          path: 'workflow',
          name: 'Workflow',
          meta: { title: '我的流程' },
          children: [
            {
              path: 'todo',
              name: 'TodoList',
              component: () => import('@/views/workflow/TodoList.vue'),
              meta: { title: '我的待办' },
            },
            {
              path: 'done',
              name: 'DoneList',
              component: () => import('@/views/workflow/DoneList.vue'),
              meta: { title: '我的已办' },
            },
          ],
        },
        {
          path: 'process',
          name: 'Process',
          meta: { title: '流程管理' },
          children: [
            {
              path: 'category',
              name: 'ProcessCategory',
              component: () => import('@/views/process/Category.vue'),
              meta: { title: '流程分类' },
            },
            {
              path: 'design',
              name: 'ProcessDesign',
              component: () => import('@/views/process/ProcessDesign.vue'),
              meta: { title: '流程设计' },
            },
            {
              path: 'design/editor',
              name: 'ProcessEditor',
              component: () => import('@/views/ProcessDesign.vue'),
              meta: { title: '流程设计器' },
            },
            {
              path: 'instance',
              name: 'ProcessInstance',
              component: () => import('@/views/process/Instance.vue'),
              meta: { title: '流程实例' },
            },
          ],
        },
        {
          path: 'system',
          name: 'System',
          meta: { title: '系统管理' },
          children: [
            {
              path: 'menu',
              name: 'MenuManagement',
              component: () => import('@/views/system/Menu.vue'),
              meta: { title: '菜单管理' },
            },
            {
              path: 'dict',
              name: 'DictManagement',
              component: () => import('@/views/system/Dict.vue'),
              meta: { title: '字典管理' },
            },
          ],
        },
      ],
    },
  ],
})

export default router
